package cmd

import (
	"github.com/spf13/cobra"
)

var (
	cfgFile    string
	maxThreads int
	speedLimit string
	outputDir  string
	tempDir    string
	proxyURL   string
	rootCmd    = &cobra.Command{
		Use:   "downloader",
		Short: "A universal download tool",
		Long: `A powerful download tool that supports multiple protocols including
HTTP(S), FTP(S), SFTP, WebDAV, BitTorrent, Magnet links, and more.`,
	}
)

func Execute() error {
	return rootCmd.Execute()
}

func init() {
	rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.config/downloader/config.yaml)")
	rootCmd.PersistentFlags().IntVar(&maxThreads, "threads", 1, "maximum number of download threads")
	rootCmd.PersistentFlags().StringVar(&speedLimit, "speed-limit", "", "download speed limit (e.g., 1MB/s)")
	rootCmd.PersistentFlags().StringVar(&outputDir, "output-dir", "./download", "directory to save downloaded files")
	rootCmd.PersistentFlags().StringVar(&tempDir, "temp-dir", "./temp", "directory to save downloaded temp files")
	rootCmd.PersistentFlags().StringVar(&proxyURL, "proxy", "", "proxy URL (e.g., socks5://127.0.0.1:1080)")

	rootCmd.AddCommand(downloadCmd)
}
